package Cantella::DJabberd::Web::Controller::Admin::User;

#the order the following IS RELEVANT
use base 'Cantella::DJabberd::Web::UI::Controller::Collection::CRUD';
use Reaction::Class;

__PACKAGE__->config
  (
   model_name => 'Admin',
   collection_name => 'users',
   action =>
   { base => { Chained => '/admin/base', PathPart => 'user' },
     create =>
     { ViewPort =>
       { field_order =>
         [qw(username full_name password confirm_password roles)],
       },
     },
     update =>
     { ViewPort =>
       { field_order => [qw/username full_name deleted_d roles/], },
     },
     list =>
     { ViewPort =>
       {
        field_order => [qw/username full_name created_d deleted_d/],
        excluded_fields => [qw/id password modified_d/],
       },
     },
     view =>
     {
      ViewPort =>
      { field_order => [qw/username full_name
                           created_d modified_d deleted_d
                           roles jids/
                       ],
        excluded_fields => [qw/id password/],
        Field => {
                  roles => { controller => 'Admin::Role' },
                  jids  => { controller => 'Admin::UserJid' },
                 },
      },
     },
   },
  );

sub base :Action :CaptureArgs(0) {
  my ($self, $c) = @_;
  $c->stash->{submenu}->current_item('users');
}

1;
